/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import java.awt.Color;
import java.awt.Frame;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JTextField;

/**
 *
 * @author minaev
 */
public class ConvIntByte {

    public static int byte2Int(byte b) {
        return b < 0 ? b + 256 : b;
    }

    public static byte int2Byte(int i) {
        return i > 127 ? (byte) (i - 256) : (byte) i;
    }

    public static void main(String[] args) {

        final Frame f = new Frame("Dookie");
        /* f.addKeyListener(new KeyListener() {
         @Override
         public void keyTyped(KeyEvent e) {
         }
         @Override
         public void keyPressed(KeyEvent e) {
         if (e.getKeyCode() == KeyEvent.VK_F6) {
         f.dispose();
         System.out.println("Frame disposed.");
         } else {
         System.out.println("Frame is still alive");
         System.out.println("Following key has been typed:"
         + e.getKeyChar() + "\nAnd it's code: "+  e.getKeyCode());
         }
         }
            
         @Override
         public void keyReleased(KeyEvent e) {
         System.out.println("Actually doing nothing here");
         }
         });*/
        JTextField tf = new JTextField("Simon Cowell");
        tf.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                System.out.println("< Do not fuck with us >");
            }

            @Override
            public void keyPressed(KeyEvent e) {
                System.out.println("Next key has been pressed: " + e.getKeyChar()
                        + " Key code :" + e.getKeyCode());
            }

            @Override
            public void keyReleased(KeyEvent e) {
                System.out.println("Next key has been released: " + e.getKeyChar()
                        + " Key code :" + e.getKeyCode());
            }
        });
        tf.setSize(200, 200);
        tf.setBackground(Color.GREEN);
        f.add(tf);
        f.pack();
        f.setSize(300, 300);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }

    public void bubbleSort(int data[], boolean isDesc) {
        int j = 0;
        int temp = 0;
        boolean swapped = true;
        while (swapped) {
            swapped = false;
            for (int i = 0; i < data.length; j++, i++) {
                if (data[i] < data[i + 1] && isDesc) {
                    temp = data[i];
                    data[i] = data[i + 1];
                    data[i + 1] = temp;
                } else if (data[i] > data[i + 1] && !isDesc) {
                    temp = data[i + 1];
                    data[i] = data[i + 1];
                    data[i] = temp;
                }
                System.out.println("Array has been sorted successfully");

            }
        }
    }

    public static double complexPercentageCalc(double sum,
            double proc, int period) {
        for (int i = 0; i < period; i++) {
            sum += sum * (proc / 100);
        }
        System.out.println("Your sum after " + period
                + " years/months/whatever "
                + sum);
        return sum;
    }

    /**
     * Remember when you were young
     * You sho
     */
    public static void inputKeyTesting() {
        
    }
}
